import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class implementSQL {
    public static void main(String[] args) {
        Connection connection=null;
        PreparedStatement statement=null;
        try {
            connection=sql.MyGetConnection();
            String sql="update book set price=? where name=?";
            statement=connection.prepareStatement(sql);
            statement.setBigDecimal(1,new BigDecimal("61.20"));
            statement.setString(2,"深入理解Java虚拟机");
            int ret=statement.executeUpdate();
            if(ret==1){
                System.out.println("更改成功");
            }else{
                System.out.println("更改失败");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }finally{
            sql.My_close(connection,statement,null);
        }
    }




















//    public static void main(String[] args) {
//        Connection connection=null;
//        PreparedStatement statement=null;
//        try {
//            connection=sql.MyGetConnection();
//            String sql="delete from borrow_info where id=(select r.id from (select max(id) id from borrow_info)r)";
//            statement=connection.prepareStatement(sql);
//            int ret=statement.executeUpdate();
//            if(ret==1){
//                System.out.println("删除成功");
//            }else{
//                System.out.println("删除失败");
//            }
//
//
//        } catch (SQLException e) {
//            e.printStackTrace();
//        }finally {
//            sql.My_close(connection,statement,null);
//        }
//
//    }
}
